package com.ruoyi.zq.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.zq.domin.dto.IndexDTO;
import com.ruoyi.common.zq.domin.vo.ActivityVO;
import com.ruoyi.zq.service.ZqIndexService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 首页接口
 *
 * @Author: LoneyFeather
 * @Date: Created in 10:16 2022/2/10
 */
@Api(tags = "首页接口")
@RestController
@RequestMapping("/index")
public class ZqIndexController extends BaseController {

    @Autowired
    private ZqIndexService indexService;

    @ApiOperation("获取登录用户数据")
//    @PreAuthorize("@ss.hasPermi('zq:notice:list')")
    @GetMapping("/basic")
    public AjaxResult basicData(){
        return AjaxResult.success(indexService.getBasicData(getUserId()));
    }


    @ApiOperation("获取登录用户参加的志愿服务活动列表")
//    @PreAuthorize("@ss.hasPermi('zq:notice:list')")
    @GetMapping("/activityList")
    public TableDataInfo activityList(IndexDTO indexDTO){
        indexDTO.setUserId(getUserId());

        startPage();
        List<ActivityVO> list = indexService.activityList(indexDTO);
        return getDataTable(list);
    }


    @ApiOperation("获取登录用户是不是学生")
    @GetMapping("isStudent")
    public AjaxResult isStudent(){
        return AjaxResult.success(indexService.isStudent(getUserId()));
    }

}
